// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { game } from "../../../../script/game/control/game";
import { ccs } from "../../../../script/util/services";
import { WinBase } from "../../../../script/wins/WinBase";



const {ccclass, property} = cc._decorator;
let arr = [
    "health",
    "mood",
    "sleep",
    "learn",
    "charm",
]
@ccclass
export default class NewClass extends WinBase {

    start () {
        ccs.gf.extendNodeName(this.nodes, this.node.parent);
        // this.setInfo();
        // this.registerEvent("updateInfo", () => {
        //    this.setInfo();
        // })
    }
    setInfo() {
        let player = game.playerMgr.heroInfo;
        this.setLabel("wealth", "富裕程度：" + (player.money >= 10000? "万元户": "贫民"));
        this.setLabel("car", "交通工具" + (player.traffic? player.traffic.name: "无"));
        this.setLabel("professional", "职业：" + (player.work != null? player.work.name: "无业游民"));
        this.setLabel("workPosition", "职位：" + (player.work != null? player.work.levelName[player.work.level]: "无业游民"));
        this.setLabel("wage", "工资：" +"职位：" + (player.work != null? player.work.income.toString(): 0));
        this.setLabel("monthIncome", "月收入：" + ccs.gf.getOmitNum(player.incomeMonth + player.assetsIncomeMonth));
        this.setLabel("yearIncome", "年收入：" + ccs.gf.getOmitNum(player.incomeYear));
        this.setLabel("monthPay", "月支出：" + ccs.gf.getOmitNum(player.payMonth + player.assetsPayMonth));
        this.setLabel("yearPay", "年支出：" + ccs.gf.getOmitNum(player.payYear));
    }
    //更新属性
    setLabel(key: string, value: string) {
       this.nodes[key].getComponent(cc.Label).string = value;
    }

}
